package com.avcdata.national.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.avcdata.aoscustommade.R;

import java.util.List;

/**
 * Created by Administrator on 2016/11/3.
 */

public class TopProductGridViewAdapter extends BaseAdapter {

    private List<String> list;
    private Context context;

    public TopProductGridViewAdapter(List<String> list, Context context) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size ();
    }

    @Override
    public Object getItem(int position) {
        return list.get ( position );
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        viewHolder holder;
        if (convertView == null) {
            holder = new viewHolder ();
            convertView = LayoutInflater.from ( context ).inflate ( R.layout.item_topbrands, null );
            holder.BrandName = (TextView) convertView.findViewById ( R.id.brandName );
            holder.selected = (ImageView) convertView.findViewById ( R.id.deleteProduct );
            holder.item_brands_ll = (RelativeLayout) convertView.findViewById ( R.id.item_brands_ll );
            convertView.setTag ( holder );
        } else {
            holder = (viewHolder) convertView.getTag ();
        }
        return convertView;
    }

    class viewHolder {
        TextView BrandName;
        ImageView selected;
        RelativeLayout item_brands_ll;
    }

}
